--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
docs/agents/conventions/tests.md 8db1f550262ba40ef35b4f081dfd893e78dc1658 (8db1f550) Text, 4.65 KB
Tc9d1d9# Test conventions
Applies when editing Ta5d6ff`tests/**/*.{py,js}`.
Tff7b72- Backend: Ta5d6ff`tests/backend/test_*.py` with pytest + asyncio auto mode.
Tff7b72- Frontend: Ta5d6ff`tests/frontend/*.test.js` with vitest + Ta5d6ff`@vue/test-utils`.
Tff7b72- Mock Ta5d6ff`window.api` for page tests. Assert toasts when outcomes are user-visible.
Tff7b72- Prefer focused files over full suite unless the user asks for broad runs.
Tff7b72- Landlock tests that apply the sandbox must run in a subprocess (one restrict per process).
Tff7b72- Shared runner: Ta5d6ff`tests/backend/landlock_integration_support.py` (Ta5d6ff`run_python_under_landlock`).
Tff7b72- Subprocess and user-local CLI probes: Ta5d6ff`tests/backend/test_landlock_integration_surfaces.py`.
Tff7b72- Unit tests for rules and ABI: Ta5d6ff`tests/backend/test_landlock_sandbox.py`.
Tff7b72- Long-running / notification soak suites can hang. Prefer timeouts and avoid piping pytest through Ta5d6ff`tail` in agent shells.
Tc9d1d9## Oracle style (no soft fuzz)
Property and fuzz tests must assert an accept or reject outcome, not only that nothing crashed.
Refuse these patterns:
Tff7b72- Bare Ta5d6ff`except Exception: pass` around the code under test
Tff7b72- Ta5d6ff`never_raises` tests with no postcondition
Tff7b72- Asserting only that a result dict has an Ta5d6ff`"ok"` key without checking True or False
Tff7b72- Mocks that return the success path for every input under a security oracle
Prefer:
Tff7b72- Independent oracle: given input X, predict accept or reject, then assert the code matches
Tff7b72- Jail oracles: on success, resolved path stays under the allowed root
Tff7b72- Closed reason sets: on Ta5d6ff`ValueError`, the message is one of the known machine reasons
Tff7b72- Round-trip or shape invariants when the API is pure parsing
Full skill: Ta5d6ff`docs/agents/skills/test-oracles/SKILL.md`.
Path jail filesystem features: Ta5d6ff`docs/agents/skills/path-jail-local-fs/SKILL.md` and Ta5d6ff`docs/agents/conventions/path-jail.md`.
Exploratory bug hunting: Ta5d6ff`docs/agents/skills/exploratory-testing/SKILL.md`.
Tc9d1d9## Frontend mega-page ownership contracts
Tff7b72- Ownership inventory: Ta5d6ff`tests/frontend/fixtures/frontend_mega_page_ownership.json`
Tff7b72- Symbol continuity: Ta5d6ff`tests/frontend/fixtures/frontend_symbol_continuity/`
Tff7b72- Scanner tests: Ta5d6ff`tests/frontend/frontendOwnershipContract.test.js`
Tff7b72- Extract workflow: Ta5d6ff`docs/agents/skills/vue-mega-page-split/SKILL.md`
Tff7b72- Refresh ownership fixture only when inventory intentionally changes:
Ta5d6ff`UPDATE_FRONTEND_OWNERSHIP=1 pnpm exec vitest run tests/frontend/frontendOwnershipContract.test.js -t ownership_fixture`
Tc9d1d9## HTTP and WS path-scanning contracts
Route and WS manifests are discovered from source text:
Tff7b72- HTTP: Ta5d6ff`tests/backend/http_api_contract_helpers.py` scans Ta5d6ff`meshchatx/meshchat.py` and Ta5d6ff`meshchatx/src/backend/http/**/*.py`
Tff7b72- WS: Ta5d6ff`tests/backend/ws_contract_helpers.py` scans the same trees plus Ta5d6ff`rns_link_manager.py` for link events
Fixtures:
Tff7b72- Ta5d6ff`tests/backend/fixtures/http_api_routes.json`
Tff7b72- Ta5d6ff`tests/backend/fixtures/ws_message_manifest.json`
Refresh only when the inventory intentionally changes:
Ta5d6ff```Ta5d6ffbash
Te6edf3UPDATE_HTTP_API_ROUTESTff7b72=T79c0ff1 uv run pytest tests/backend/test_http_api_contract.py -k meshchat_http_routes_match_fixture
Te6edf3UPDATE_WS_MESSAGE_MANIFESTTff7b72=T79c0ff1 uv run pytest tests/backend/test_ws_json_contracts.py -k manifest_matches_meshchat
Ta5d6ff```
JSON response schemas stay in Ta5d6ff`tests/backend/` (Ta5d6ff`api_json_contract_schemas.py`, Ta5d6ff`http_api_response_schemas.py`, registry files). See Ta5d6ff`docs/agents/module-ownership.md`.
Tc9d1d9## Extended Edge Case Tester (EECT) and Live Validation (LV)
Tff7b72- EECT packs live under Ta5d6ff`tests/backend/eect/packs/` and use marker Ta5d6ff`eect`.
Tff7b72- LV ladder lives under Ta5d6ff`tests/backend/eect/live/` and uses marker Ta5d6ff`live_validation`.
Tff7b72- Replay a failure with Ta5d6ff`MESHCHAT_EECT_SEED=<seed>` (printed on assert failure).
Tff7b72- Commands: Ta5d6ff`task test:eect`, Ta5d6ff`task test:lv:l0`, Ta5d6ff`MESHCHAT_LIVE_VALIDATION=1 task test:lv`.
Tff7b72- LV L2/L3 are opt-in (Ta5d6ff`MESHCHAT_LIVE_VALIDATION=1` or Ta5d6ff`MESHCHAT_LIVE_RETICULUM=1`). L0/L1 stay CI-safe.
Tc9d1d9## HTTP and WebSocket contract scanners
Tff7b72- HTTP route inventory: Ta5d6ff`tests/backend/http_api_contract_helpers.py` scans
Ta5d6ff`meshchatx/meshchat.py` and all Ta5d6ff`meshchatx/src/backend/http/**/*.py`.
Tff7b72- WS message inventory: Ta5d6ff`tests/backend/ws_contract_helpers.py` scans the same trees
(plus Ta5d6ff`rns_link_manager.py` for Ta5d6ff`rns.link.*` broadcasts).
Tff7b72- Refresh HTTP fixture only when routes intentionally change:
Ta5d6ff`UPDATE_HTTP_API_ROUTES=1 uv run pytest tests/backend/test_http_api_contract.py -k meshchat_http_routes_match_fixture`
Tff7b72- Refresh WS fixture only when message types intentionally change:
Ta5d6ff`UPDATE_WS_MESSAGE_MANIFEST=1 uv run pytest tests/backend/test_ws_json_contracts.py -k manifest_matches_meshchat`
Tff7b72- Domain ownership for routes vs schemas: Ta5d6ff`docs/agents/module-ownership.md`.
Tff7b72- Extraction workflow: Ta5d6ff`docs/agents/skills/meshchat-orchestration-split/SKILL.md`.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────